package com.zero.jewelry.service.Impl;

import java.util.List;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zero.common.core.utils.DateUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import com.zero.jewelry.mapper.ProductPartitionRelMapper;
import com.zero.jewelry.domain.ProductPartitionRel;
import com.zero.jewelry.service.IProductPartitionRelService;

/**
 * 产品分区关联Service业务层处理
 *
 * @author cai-xu-kun
 * @date 2025-08-01
 */
@Service
@RequiredArgsConstructor
public class ProductPartitionRelServiceImpl extends ServiceImpl<ProductPartitionRelMapper, ProductPartitionRel> implements IProductPartitionRelService {

    private final ProductPartitionRelMapper productPartitionRelMapper;

    /**
     * 查询产品分区关联分页
     *
     * @param productPartitionRel 产品分区关联
     * @param p 分页数据
     * @return 产品分区关联
     */
    @Override
    public Page<ProductPartitionRel> selectProductPartitionRelListPage(ProductPartitionRel productPartitionRel, Page<ProductPartitionRel> p) {
        return productPartitionRelMapper.selectProductPartitionRelListPage(productPartitionRel, p);
    }

    /**
     * 查询产品分区关联
     *
     * @param productId 产品分区关联主键
     * @return 产品分区关联
     */
    @Override
    public ProductPartitionRel selectProductPartitionRelByProductId(Long productId) {
        return productPartitionRelMapper.selectProductPartitionRelByProductId(productId);
    }

    /**
     * 查询产品分区关联列表
     *
     * @param productPartitionRel 产品分区关联
     * @return 产品分区关联
     */
    @Override
    public List<ProductPartitionRel> selectProductPartitionRelList(ProductPartitionRel productPartitionRel) {
        return productPartitionRelMapper.selectProductPartitionRelList(productPartitionRel);
    }

    /**
     * 新增产品分区关联
     *
     * @param productPartitionRel 产品分区关联
     * @return 结果
     */
    @Override
    public int insertProductPartitionRel(ProductPartitionRel productPartitionRel) {
        productPartitionRel.setCreateTime(DateUtils.getNowDate());
        return productPartitionRelMapper.insertProductPartitionRel(productPartitionRel);
    }

    /**
     * 修改产品分区关联
     *
     * @param productPartitionRel 产品分区关联
     * @return 结果
     */
    @Override
    public int updateProductPartitionRel(ProductPartitionRel productPartitionRel) {
        return productPartitionRelMapper.updateProductPartitionRel(productPartitionRel);
    }

    /**
     * 批量删除产品分区关联
     *
     * @param productIds 需要删除的产品分区关联主键
     * @return 结果
     */
    @Override
    public int deleteProductPartitionRelByProductIds(Long[] productIds) {
        return productPartitionRelMapper.deleteProductPartitionRelByProductIds(productIds);
    }

    /**
     * 删除产品分区关联信息
     *
     * @param productId 产品分区关联主键
     * @return 结果
     */
    @Override
    public int deleteProductPartitionRelByProductId(Long productId) {
        return productPartitionRelMapper.deleteProductPartitionRelByProductId(productId);
    }
}
